package com.woniuxy.topic.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {
    @Bean //生成bean对象的时候，会使用方法名字作为bean的名字
    public Queue topicQueue1(){
        return new Queue("TopicQueue1");
    }
    @Bean
    public Queue topicQueue2(){
        return new Queue("TopicQueue2");
    }

    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("topicEx");
    }
    @Bean
    public Binding bindingTopic1(){
        return BindingBuilder.bind(topicQueue1()).to(topicExchange()).with("*.orange.*");
    }

    @Bean
    public Binding bindingTopic2(){
        return BindingBuilder.bind(topicQueue2()).to(topicExchange()).with("*.*.black");
    }
    @Bean
    public Binding bindingTopic3(){
        return BindingBuilder.bind(topicQueue2()).to(topicExchange()).with("only.#");
    }
}
